//
//  JingDianMapCell.m
//  IYLM
//
//  Created by Jian-Ye on 12-11-8.
//  Copyright (c) 2012年 Jian-Ye. All rights reserved.
//

#import "JingDianMapCell.h"

@implementation JingDianMapCell
@synthesize lbName;
@synthesize lbAddress;
@synthesize lbCuisine;
@synthesize lbScore;
@synthesize score;
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/
-(void)setScore:(NSNumber *)s {
    //    if (![s isEqualToNumber:score]) {
    score = [s copy];
    int z = [score intValue];
    int empty=0;
    if(z==0){
        for(int i=0;i<5;i++){
            UIImageView *im = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ic_star_empty.png"]];
            im.frame = CGRectMake(i*12+5, 0, 12, 12);
            //            im.contentMode = UIViewContentModeScaleAspectFit;
            [self.lbScore addSubview:im];
        }
    }else{
        for(int i=0;i<z;i++){
            UIImageView *im = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ic_star.png"]];
            im.frame = CGRectMake(i*12+5, 0, 12, 12);
            [self.lbScore addSubview:im];
            empty++;
        }
        if(z< [score floatValue]){
            UIImageView *im = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ic_star_half.png"]];
            im.frame = CGRectMake((z)*12+5, 0, 12, 12);
            [self.lbScore addSubview:im];
            empty++;
            z++;
        }
        for(int i=0;i<5-empty;i++){
            UIImageView *im = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ic_star_empty.png"]];
            im.frame = CGRectMake(z++*12+5, 0, 12, 12);
            //            im.contentMode = UIViewContentModeScaleAspectFit;
            [self.lbScore addSubview:im];
        }
    }
    //        self.scoreLable.text = score;
    //    }
}

@end
